package strutil

import (
	"github.com/fatih/color"
	"strings"
)

var (
	Error  = color.New(color.FgHiRed, color.Bold).Sprintf("[ Error ] ")
	Info   = color.New(color.FgHiGreen, color.Bold).Sprintf("[ Info ] ")
	Waring = color.New(color.FgHiYellow, color.Bold).Sprintf("[ Waring ] ")
)

func SnakeToCamelCase(input string) string {
	// 分割字符串
	words := strings.Split(input, "_")
	// 转换为驼峰命名
	for i := 0; i < len(words); i++ {
		words[i] = strings.Title(words[i])
	}
	// 连接字符串
	output := strings.Join(words, "")

	return output
}

func FirstToLower(data string) string {
	count := len(data)
	if count < 1 {
		return ""
	} else if count == 1 {
		return strings.ToLower(data)
	} else {
		firstChar := data[0:1]
		return strings.ToLower(firstChar) + data[1:count]
	}
}

func ColorLabelStr(msg string) string {
	return color.New(color.FgHiYellow, color.Bold).Sprintf(msg)
}

func ColorValueStr(msg string) string {
	return color.New(color.FgHiMagenta, color.Bold).Sprintf(msg)
}
func ColorValueFormatStr(pattern string, msg interface{}) string {
	return color.New(color.FgHiMagenta, color.Bold).Sprintf(pattern, msg)
}
